<?php

/** libraries
 * http://docs.joomla.org/JToolBarHelper
 */

/* No direct access to this file */
defined('_JEXEC') or die('Restricted access');

/* import Joomla view library */
jimport('joomla.application.component.view');

class bgViewbg extends JView
{
	/* Overwriting JView display method */
	function display($tpl = null) 
	{
        $model = $this->getModel();
       
        switch(JRequest::getVar('task')){
            case 'edit':
                JToolBarHelper::title( '体育館の施設の情報作成及び編集', 'redirect.png' );
                
                JToolBarHelper::save('save','登録');
            	JToolBarHelper::cancel('cancel', 'キャンセル');
                $this->setLayout('edit');
                
                break;
                
            case 'add':
            	JToolBarHelper::title( '体育館の施設の情報作成及び編集', 'redirect.png' );
                
                JToolBarHelper::save('save','登録');
            	JToolBarHelper::cancel('cancel', 'キャンセル');
                $this->setLayout('add');
                
            	break;
                
            /* upload file csv */
            case 'upload':
                /* if file csv not empty */
                if ($_FILES[csv][size] > 0)
                {  
                    /* read file csv, return array */
                    $this->list = HelperBG::readCSV($_FILES['csv']['tmp_name']);
                    $model->uploadCSV($this->list); 
                    
                    $this->list['filter_search'] = &JRequest::getVar('filter_search');
                    $this->list['status'] = &JRequest::getVar('status');
                    $this->rows =& $model->getAll($this->list); 
                    $this->pagination =& $this->get('Pagination');
                    
                    JToolBarHelper::title( '体育館の施設一覧の管理', 'redirect.png' );
                    JToolBarHelper::deleteList('', 'remove','削除');
                    $this->setLayout('default');
                    
                    break;
                }
            
            /* default value */	    
            default :
                $this->list['filter_search'] = &JRequest::getVar('filter_search');
                $this->list['status'] = &JRequest::getVar('status');
                $this->rows =& $model->getAll($this->list); 
                $this->pagination =& $this->get('Pagination');
                
            	JToolBarHelper::title( '体育館の施設一覧の管理', 'redirect.png' );
            	JToolBarHelper::deleteList('', 'remove','削除');
		}   
		parent::display();
	}
}




